package com.albd.utils;

import java.util.List;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;

public class SystemUtil {
	
	public static boolean isServiceRunning(Context context, String name){
		boolean isRunning = false;
		if(TextUtils.isEmpty(name)){
			return isRunning;
		}
		ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
		List<RunningServiceInfo> services = am.getRunningServices(Integer.MAX_VALUE);
		if(services.size() <= 0) {
			return isRunning;
		}
		
		for (RunningServiceInfo runningServiceInfo : services) {
			if(name.equals(runningServiceInfo.service.getClassName())){
				isRunning = true;
				break;
			}
		}
		return isRunning;
	}
}
